#include <bits/stdc++.h>
using namespace std;

#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
	{                                         \
		cerr << "\033[32;1m" << #x << " -> "; \
		err(x);                               \
	}
void err()
{
	cerr << "\033[39;0m" << endl;
}
template <typename T, typename... A>
void err(T a, A... x)
{
	cerr << a << ' ';
	err(x...);
}
#else
#define dbg(...)
#endif

typedef long long LL;

const int N = 3e6 + 50;

int a[N], b[N];

int n;

int collect(int a[], int n, int l, int r, int tar[])
{
	int len = 0;
	for (int i = 0; i < n; ++i)
	{
		if (a[i] <= r && a[i] >= l)
			tar[len++] = i;
	}
	return len;
}

int pa[N], pb[N];

LL diff(int a[], int b[], int n)
{
	LL res = 0;
	for (int i = 0; i < n; ++i)
	{
		if (a[i] >= b[i])
			res += a[i] - b[i];
		else
			res += b[i] - a[i];
	}
	return res;
}

int main(int argc, char const *argv[])
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &b[i]);
	}
	int mid = n / 2;

	LL ans = 1e18;
	if (n % 2 == 0)
	{
		collect(a, n, 1, mid, pa);
		collect(b, n, mid+1, n, pb);
		ans = min(ans, diff(pa, pb, n/2));
	}
	else
	{
		collect(a, n, 1, mid, pa);
		collect(b, n, mid+2, n, pb);
		ans = min(ans, diff(pa, pb, n/2));
		collect(a, n, 1, mid+1, pa);
		collect(b, n, mid+1, n, pb);
		ans = min(ans, diff(pa, pb, n/2+1));
	}
	printf("%lld\n", ans);
	

	return 0;
}